package com.lagou.lagouserviceuser8180.controller;

import com.lagou.lagouserviceuser8180.bean.User;
import com.lagou.lagouserviceuser8180.service.AuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
注册，登录逻辑
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private AuthCodeService authCodeService;

    @GetMapping("/register/{email}/{password}")
    public Object login(@PathVariable("email") String email,
                        @PathVariable("password") String password) {
        System.out.println("挑战过来了");
        String authCode = authCodeService.getAuthCode();
        User user = new User();
        user.setCode(authCode);
        user.setEmail(email);
        user.setPassword(password);
        return user;
    }
}
